#include <iostream>
#include <map>
using namespace std;

int j[] = {1,3,7,9};
int x[] = {2,3,4,5,7};

bool check(int pos)
{
    if(pos <= 10)
    {
        return false;
    }
    map<int,int> mp;
    while(pos)
    {
        mp[pos%10]++;
        pos/=10;
    }
    for(int i = 0;i < 4;i++)
    {
        if(mp.count(j[i]))
        {
            mp[j[i]]--;
            for(auto& er:mp)
            {
                if((er.first) == 0 || mp[er.first] == 0)
                {
                    continue;
                }
                bool flag = true;
                int ans = (er.first) * 10 + j[i];
                for(auto&e:x)
                {
                    if(ans % e == 0)
                    {
                        flag = false;
                        break;
                    }
                }
                if(flag)
                {
                    return true;
                }
            }
            mp[j[i]]++;
        }
    }
    return false;
}

int main() {
    int a,b;
    cin >> a >> b;
    int ans = 0;
    for(int i = a;i <= b;i++)
    {
        if(check(i))
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}
// 64 位输出请用 printf("%lld")